﻿namespace MvcScriptManager.UniqueKeyEncoding
{
    using System;

    /// <summary>
    /// Factory class for instantiating the appropriate <see cref="IUniqueKeyEncoder"/> implementation
    /// </summary>
    public class UniqueKeyEncoderFactory
    {
        /// <summary>
        /// Creates a new <see cref="IUniqueKeyEncoder"/> implementation based on the chosen
        /// scheme
        /// </summary>
        /// <param name="scheme">The unique key encoding scheme</param>
        /// <returns>The <see cref="IUniqueKeyEncoder"/> implementation</returns>
        /// <exception cref="NotImplementedException">If the scheme is not recognised</exception>
        public IUniqueKeyEncoder GetEncoderForScheme(UniqueKeyEncodingScheme scheme)
        {
            switch (scheme)
            {
                case UniqueKeyEncodingScheme.OneWayHash:
                    return new UniqueKeyOneWayHash();
                case UniqueKeyEncodingScheme.TwoWayEncoding:
                    return new UniqueKeyTwoWayEncoding();
                default:
                    throw new NotImplementedException("UniqueKeyEncoderFactory does not support the requested scheme");
            }
        }
    }
}
